Do not setup log handlers to write to stderr#758
Do not setup log handlers to write to stderr#758draftcode wants to merge 1 commit intotestcontainers:mainfrom
Conversation
By setting up a handler in the library, the library users do not have a good control on how/where to write the logs. Do not set a handler from the library.
|
we should add docs and do a logging overhaul i think - e.g. https://github.com/testcontainers/testcontainers-java/blob/2707f3143d3cfa8351f727bfd5752c1155818bd6/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L665C1-L672C6 |
|
@alexanderankin what do you mean with a logging overhaul? Logging is always quite language specific as it requires global objects. I am with draftcode that a libary should not setup a logger, it only should log. I would even go that far, that the library should not even define the log level. It up to the user of the lib to define it. I.e. import logging
from typing import Final
LOGGER: Final = logging.getLogger("testcontainers")
LOGGER.setLevel(logging.INFO)This would set the log level to all Besides this, there is nothing more to do. Why this is importantI am using testcontainers in pytest plugin, as I need containers to be started before imports are done (legacy code, that setups databases during import...). So being able to simply disable/change the handler all together would be nice. |
|
Agree 💯 here. I'd go so far as to suggest |
|
closed in favor of #836 |
By setting up a handler in the library, the library users do not have a good control on how/where to write the logs. Do not set a handler from the library.